#!/bin/sh

cat WatchList |grep -v "#" |while read line 
do
    stock=`echo $line |awk '{print $1}'`
    rest=`echo $line |awk '{print $2}'`
    dir=`echo $rest|cut -c1`
    target=`echo $rest|cut -c2-`
    price=`curl -stderr "http://download.finance.yahoo.com/d/quotes.csv?s=$stock&f=l1" |dos2unix`
    if [ `echo "$price $dir $target" |bc` = 1 ]; then
        echo $stock $rest $dir $target
 	mail -s "ALERT $stock $dir $target Price=$price" qiming_he@freddiemac.com < /dev/null
    fi
done
